    let { ajax , $ } = Utils;
    //console.log(ajax,$);
    let [form , btn ] = [ 
                            $("#login-form"),
                            $("#btn")
                      ];
    console.log(form);
    form.addEventListener( "submit" , evt => {
          let e = evt || window.event;
          e.preventDefault();
    })
    btn.addEventListener( "click" , evt => {
          let [
                userValue ,
                pwdValue
          ] = [
                $("input[name=username]").value,
                $("input[name=password]").value,
          ]

          // 禁用按钮;
          btn.disabled = "disabled";
          btn.innerHTML = "loading...";
          let url = "http://localhost/seven/XDW/meizu_project/src/php/login.php";
          let data = {
                username : userValue,
                password : pwdValue
          }

          ajax(url , {
                data ,
                type : "POST",
                dataType : "json"
          })
          .then( res => {
                // console.log(res);
                switch(res.stateCode){
                      case 0 : 
                            alert("登陆参数不全");
                            break;
                      case 2 : 
                            alert("数据库连接失败");
                            break;
                      case 3 : 
                            alert("用户名不存在");
                            break;
                      case 4 : 
                            alert("密码错误");
                            break;
                      case 1 : 
                            alert("登陆成功");
                            location.href = "http://localhost/seven/XDW/meizu_project/src/index.html";
                            break;
                }

                btn.removeAttribute("disabled");
                btn.innerHTML = "登陆";

                console.log(res);
          })

    })

    // 先发一个请求,验证是否存在tocken ,如果存在就不用登陆了;如果不存在我继续去登陆;

    function validateTocken(){
          let url = "http://localhost/seven/XDW/meizu_project/src/php/login.php";
          ajax(url)
          .then( res => {
                res = JSON.parse(res)
                console.log(res.state);
                if(res.state){
                      return false;
                }
                // this.user_info.innerHTML = `<li>个人中心</li> <li>${res.username}</li>`;
                location.href = "http://localhost/seven/XDW/meizu_project/src/index.html";

                //form.innerHTML = "用户名为:" + res.username + "<button id='exit'>退出登陆</button>";
          })
    }
    validateTocken()